#ifndef WAVEFORMWIDGET_H
#define WAVEFORMWIDGET_H

#include <QWidget>
#include <soundsample.h>
#include <soundsampleaiff.h>
#include <soundsamplemp3.h>
#include <soundsamplewav.h>
#include "CursorWidget.h"
#include <QMouseEvent>
#include "SoundPlayer.h"

class WaveformWidget : public QWidget
{
    Q_OBJECT

public:

    explicit WaveformWidget( QWidget *parent = 0 );
    ~WaveformWidget();

    // inherited from QWidget
    void paintEvent(QPaintEvent *);
    QSize sizeHint() const;

    // getters
    QString getFilepath () { return this->filepath; }
	
	// getters and setters for the plotData
	void setPlotDataUp ( int* _plotDataUp );
	void setPlotDataDown ( int* _plotDataDown );
	int* getPlotDataUp () const;
	int* getPlotDataDown() const;
	
	void setMaxBitdepthValue ( int value );
	int getMaxBitdepthValue ();
	
	CursorWidget* getCursorWidget() { return cursor; }

private :
    QString filepath;
	CursorWidget* cursor;
	
    // plotData storing the data to paint afterwards
    int* plotDataUp;
    int* plotDataDown;
	
	// int storing the maximum value of an 8, 16 or 24 bit file
	// used to scale the waveform vertically
	int maxBitdepthValue;
	
	// the sound player instance to change the playback position 
	// on mouse click
	SoundPlayer* player;
	
	// Override from QWidget
	void mousePressEvent(QMouseEvent *event);
	
};

#endif // WAVEFORMWIDGET_H
